<!DOCTYPE html>
<html>
<head>
<title>组织机构</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=8, IE=9, IE=10, chrome=1" />
<meta name="renderer" content="webkit" />
<link href="../framework/css/font.css" rel="stylesheet" />
<link href="../framework/miniui/themes/material/miniui.css" rel="stylesheet" />
<link href="../framework/css/app.min.1.css" rel="stylesheet" type="text/css" />
<link href="../framework/css/app.min.2.css" rel="stylesheet" type="text/css" />
<script src="../framework/main.js"></script>
<style type="text/css">
.input-group-addon{width:160px;text-align: right;}
.ceshi{
display:none;
} 
</style> 
<script type="text/javascript">
	Page.onLoad(function(){});

	 function checkMobile(str) {
		 var myreg=/^[1][3,4,5,6,7,8][0-9]{9}$/;
         if (!myreg.test(str)) {
             return false;
         } else {
             return true;
         }

	 }
	//添加
	function findMin() {
		var Mobile = mini.get("Mobile").value;
		var mobileAvailable = checkMobile(Mobile);
		if(!mobileAvailable){
			top.mini.showTips({content:"手机号格式不正确,请输入11位有效手机号!",state:'error'});
			return;
		}
		var UserName = mini.get("UserName").value;
		if(!UserName){
			top.mini.showTips({content:"机构名称不能为空!",state:'error'});
			return;
		}
		var Type = mini.get("Type").value;
		var dc = {Mobile:Mobile,UserName:UserName,Type:Type};
	    Server.sendRequest("NewAccountNumber.addMember", dc,function(response){
	    	 if(response.Message == "该账号不存在请添加"){
		    	mini.get("Type").setValue(1);
	 			findMin();
	 		}else if(response.Message == "本账号为系统已有的二级账号，从系统内剔除，才能增添为一级机构账号"){
	 			top.mini.showTips({content:response.Message,state:'error'}); 
	 		}else if(response.Message == "本账号为游客账号，是否更改为一级机构账号?"){
	 		    top.mini.showTips({content:response.Message,state:'success'});
	 		    mini.get("Type").setValue(0);
	 		}else{
				if(response._STATUS==1){
					top.mini.showTips({content:response.Message,state:'success'});
					if("成功修改为一级账号" == response.Message || "一级账号创建成功" == response.Message){
						window.CloseOwnerWindow();
					}
				}else{
					top.mini.showTips({content:response.Message,state:'error'});
				}
		 	}
		});
	}  
</script>
</head>
	<body class="dialog">
			<form id="form3">
				<div class="container-fluid">
					<div class="row">
						<div class="col-xs-12">
							<div class="input-group">
							<span class="input-group-addon">&nbsp;</span>
							</div>
							<div class="input-group">
							<span class="input-group-addon">&nbsp;</span>
							</div>
							<div class="input-group">
							     <p>
									<span >账&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号:</span>
									<input id="Mobile" name="Mobile" type="text" required="true"  class="mini-textbox" verify="Length<20" vtype="Mobile" style="width:150px" />
									<input id="Type" name="Type" type="hidden" value="3"  class="mini-textbox" verify="Length<20" vtype="Type" style="width:150px;display:none" />
								 </p>
								 <p>
								 <span >机构名称:</span>
									<input id="UserName" name="UserName" required="true" type="text"  class="mini-textbox" verify="Length<20" vtype="UserName" style="width:150px" />
								 </p>
								  
								 <!--<a style="float:right" id="build" class="mini-button ceshi" onclick="findAdmin();" plain="true">创建</a> -->
								
							</div>
							<!-- <a style="float:right" id="xiugai"  class="mini-button ceshi" onclick="findAdmin();" plain="true">确定修改</a> -->
							<a style="float:right"  id="determine" class="mini-button" onclick="findMin();" plain="true">添加</a>
							
						</div>
					</div>
				</div>
			</form>
	</body>
</html>